import { UserProfilesAPI } from "@/request/api"
export default {
    namespaced: true,
    state: {
        userInfo: {
            nickName: "哈哈哈",
            headImg: require("../../assets/img/bb3.png"),
            coin: 88
        },
        cartTotal: 2
    },
    mutations: {
        changeUserInfo(state, paylode) {
            state.userInfo = paylode.userInfo
            state.cartTotal = paylode.cartTotal
        },
        //初始化仓库
        initUserInfo(state) {
            state.userInfo = {
                nickName: "略略略",
                headImg: require("../../assets/img/bb3.png"),
                coin: 0
            },
                state.cartTotal = 8
        }
    },
    actions: {
        async asyncchangeUserInfo({ commit }) {
            let user = await UserProfilesAPI()
            commit("changeUserInfo", user.data)
        }
    }

}